package com.kx.smsplantform.config;

import com.kx.smsplantform.job.MonitorBalanceJob;
import com.kx.smsplantform.job.MonitorRabbitJob;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Sun
 * @Date 2021/7/7 22:11
 */
@Configuration
public class JobScheduleConfig {
     //配置到ScheduleJobBootstrap
    @Bean
    public ScheduleJobBootstrap monitorRabbitJobBootstrap(
            CoordinatorRegistryCenter zookeeperRegistryCenter,
            MonitorRabbitJob monitorRabbitJob,
            @Qualifier("monitorRabbitConfiguration") JobConfiguration monitorRabbitConfiguration){
        ScheduleJobBootstrap jobBootstrap = new ScheduleJobBootstrap(zookeeperRegistryCenter,monitorRabbitJob,monitorRabbitConfiguration);
        jobBootstrap.schedule();
        return jobBootstrap;
    }
    @Bean
    public ScheduleJobBootstrap monitorBalanceJobBootstrap(
            CoordinatorRegistryCenter zookeeperRegistryCenter,
            MonitorBalanceJob monitorBalanceJob,
            @Qualifier("monitorBalanceConfiguration") JobConfiguration monitorBalanceConfiguration){
        ScheduleJobBootstrap jobBootstrap = new ScheduleJobBootstrap(zookeeperRegistryCenter,monitorBalanceJob,monitorBalanceConfiguration);
        jobBootstrap.schedule();
        return jobBootstrap;
    }
}
